package com.sgb.zhaocai.view.demand.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.zhaocai.BR;
import com.sgb.zhaocai.R;
import com.sgb.zhaocai.entity.LabourWorkListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * Time:2021/7/2
 * AUTHOR:F_Q
 * Description:
 */
public class LabourWorkAdapter extends BaseRecycleAdapter<LabourWorkListEntity> {

    public LabourWorkAdapter(Context context, List<LabourWorkListEntity> datas) {
        super(context, R.layout.zc_labourwork_items, datas);
    }
    @Override
    public void onBindViewHolder(ItemViewHolder holder, @SuppressLint("RecyclerView") int position) {
        super.onBindViewHolder(holder, position);
        TextView offers = holder.itemView.findViewById(R.id.offer);
        offers.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                OnItemStateOperate.itemOffer(datas.get(position));
            }
        });
    }


    @Override
    public void convert(ItemViewHolder holder, LabourWorkListEntity entity) {
        holder.setBinding(BR.viewModel, entity);
    }

    private OnItemStateOperate OnItemStateOperate;

    public void setOnItemStateOperate(OnItemStateOperate onItemStateOperate) {
        OnItemStateOperate = onItemStateOperate;
    }

    public interface OnItemStateOperate {
        void itemOffer(LabourWorkListEntity entity);
    }
}
